<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="cap.bean.User" %>
<%@ page import="cap.bean.Category" %>
<%@ page import="cap.bean.SysCategory" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
    User user = (User)request.getSession().getAttribute("user");//用户资料
    List<Category> cgList = (List<Category>)request.getAttribute("cgList");//个人分类信息
    List<SysCategory> scgList = (List<SysCategory>)request.getAttribute("scgList");//系统分类信息
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>博客</title>
    <link href="<%=basePath%>bootstrap/css/blog-home.css"/>
    <link href="<%=basePath%>bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="<%=basePath%>bootstrap/js/jquery-2.1.1.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="<%=path%>/user?method=index">博客</a>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse navbar-ex1-collapse">
            <ul class="nav navbar-nav">
                <li><a href="<%=path%>/index.jsp">首页</a></li>
            </ul>
            <c:if test="${null!=user}">
                <ul class="nav navbar-nav">
                    <li><a href="<%=basePath %>user?method=myblog&userId=${user.id}">我的博客</a></li>
                </ul>
                <ul class="nav navbar-nav">
                    <li><a href="<%=basePath %>article?method=manage&userId=${user.id}"><i class="icon-cog"></i> 博文管理</a></li>
                    <li><a href="<%=basePath %>category?method=manage&userId=${user.id}"><i class="icon-cog"></i> 分类管理</a></li>
                    <li><a href="<%=basePath %>comment?method=manage&userId=${user.id}"><i class="icon-cog"></i> 评论管理</a></li>
                </ul>
            </c:if>
            <c:if test="${null==user}">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="<%=path%>/login.jsp" target="_self">登录</a></li>
                    <li><a href="<%=path%>/register.jsp" target="_self">注册</a></li>
                </ul>
            </c:if>
            <c:if test="${user!=null}">
                <div class="pull-right">
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="#">欢迎，${user.userName}</a></li>
                        <li><a href="<%=basePath%>user?method=profile&id=${user.id}"><i class="glyphicon glyphicon-cog"></i> 编辑个人信息</a></li>
                        <c:if test="${user.isApplied==1}">
                            <li><a href="<%=basePath%>user?method=bloginfo&userId=${user.id}"><i class="glyphicon glyphicon-cog"></i> 编辑博客信息</a></li>
                        </c:if>
                        <li><a href="<%=path%>/user?method=logout"><i class="glyphicon glyphicon-off"></i> 登出</a></li>
                    </ul>
                    </li>
                    </ul>
                </div>
            </c:if>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container -->
</nav>
<c:if test="${null!=user}">
    <div class="container" style="position: absolute;top: 20px;left: 390px">
        <div class="row col-md-12">
            <div class="col-md-12">
                <div class="col-md-12">
                    <ol class="breadcrumb">
                        <li><a href="<%=basePath%>article?method=manage&userId=${user.id}">博文管理</a></li>
                        <li class="active">新建文章</li>
                    </ol>
                </div>
                <form class="form-horizontal" name="add_artical_form" action="<%=basePath %>article?method=save&userId=${user.id}" method="post">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="title">标题</label>
                            <input class="form-control" id="name" id="title" name="title" type="text" >
                        </div>
                        <div class="form-group">
                            <label for="sys_category">系统分类</label>
                            <select class="form-control"  id="sys_category" name="sys_category">
                                <%
                                    if ((null != scgList) && (scgList.size() > 0)) {
                                        for (SysCategory scg : scgList) {
                                %>
                                <option value="<%=scg.getId() %>" selected=""><%=scg.getCategoryName() %></option>
                                <%  }
                                } else { %>
                                <option><%="默认分类" %></option>
                                <% } %>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="category">个人分类</label>
                            <select class="form-control" id="category" name="category">
                                <%
                                    if ((null != cgList) && (cgList.size() > 0)) {
                                        for (Category cg : cgList) {
                                            if (cg.getIsDelete() == 0) {
                                %>
                                <option value="<%=cg.getId() %>" selected=""><%=cg.getCategoryName() %></option>
                                <%     }
                                }
                                } else { %>
                                <%="无分类" %>
                                <% } %>
                            </select>
                        </div>
                        <div class="form-group">
                            <textarea class="form-control" id="message1" name="summary"  placeholder="摘要" rows="5"></textarea>
                        </div>

                        <div class="form-group">
                            <textarea class="form-control" id="message2" name="content"  placeholder="文章内容" rows="5"></textarea>
                        </div>

                        <div class="form-group">
                            <button id="contact-submit" type="submit" class="btn btn-primary input-medium pull-right">保存</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</c:if>
<div class="container" style="position:absolute;bottom:12px;left:420px;">
    <hr>
    <footer style="text-align: center">
        <div class="row">
            <div class="col-lg-12">
                <p>
                    &middot;网站创建到目前访问人数：<%=(Integer)session.getAttribute("num") %>
                </p>
            </div>
        </div>
    </footer>
</div>
<div><audio autoplay="autoplay" loop="true"><source src="music/1.mp3"></audio></div>
</body>
</html>